<?php

namespace app\controller;

use app\BaseController;
use app\common\middleware\ControllerIndex;
use app\common\model\User;
use app\event\Explosion;
use app\validate\IndexValidate;
use liketp\database\Builder;
use liketp\database\Query;
use liketp\facade\Db;
use liketp\facade\Event;
use liketp\facade\Route;
use PDO;
use liketp\Log;

class Index extends BaseController
{
    public $middleware = [
        //ControllerIndex::class
    ];

    public function test()
    {
        return __METHOD__;
    }

    public function before_test()
    {
        echo 'before_';
        echo '<br />';
    }

    public function index()
    {
        //User::destroy([['name', 'like', 'name%']]);
        $batchData = [];
        for ($i = 0; $i < 10; $i++) {
            $batchData[] = [
                'id' => $i + 61,
                'name' => '~~~name' . $i,
                'email' => '###email' . $i,
                'password' => '123'
            ];
        }
        //$user = new User();
        //$user = $user->find(22);
        $res = User::saveAll($batchData);
        halt($res);
        $user ?? halt($res, $user);
        return 'index';
    }

    public function ping()
    {
        return __METHOD__;
    }

    public function xiao()
    {
        return __METHOD__;
    }

    public function sayHi($name = 'kk')
    {
        return 'Hi, ' . $name;
    }
}
